const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const app = express()
const homeRouter = require('./route/home')
/*const mysql = require('./mysql')*/
const carousel = require('./model/Carousel')

/*开放公共资源*/
app.use('/public/',express.static(path.join(__dirname,'./public')))
app.use('/node_modules/',express.static(path.join(__dirname,'./node_modules')))

/* 配置解析表单 POST 请求体插件（注意：一定要在 app.use(router) 之前 ）
 parse application/x-www-form-urlencoded*/
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())

app.use(homeRouter)

/*
检测mysql是否连接成功
mysql
	.authenticate()
	.then(() => {
		console.log('mysql connect success');
	})
	.catch(err => {
		console.error('err:', err);
	});*/

app.listen(33333,function () {
	console.log('项目启动,范围地址: http://127.0.0.1:33333');
})